package com.hbpu.maven.spring.ioc;

import com.hbpu.maven.spring.ioc.bean.Car;
import com.hbpu.maven.spring.ioc.bean.Dog;
import com.hbpu.maven.spring.ioc.bean.Person;
import com.hbpu.maven.spring.ioc.bean.User;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;

import java.util.Map;

@SpringBootApplication
public class Spring01IocApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext ioc = SpringApplication.run(Spring01IocApplication.class, args);
        System.out.println("ioc" + ioc);

        System.out.println("===========================");
//        String[] beanDefinitionNames = ioc.getBeanDefinitionNames();
//        for (String beanDefinitionName : beanDefinitionNames) {
//            System.out.println(beanDefinitionName);
//        }
//        Object person = ioc.getBean("person");
//        System.out.println(person);

//        Map<String, Person> beansOfType = ioc.getBeansOfType(Person.class);
//        System.out.println(beansOfType);
//        ioc.getBean("person");
//        Object dog = ioc.getBean("dog");
//        System.out.println(dog);

//        Dog bean = ioc.getBean(Dog.class);
//        System.out.println(bean.getAge());
//        Map<String, Dog> dogBeans = ioc.getBeansOfType(Dog.class);
//        System.out.println("Registered Dog Beans: " + dogBeans);
//        Person bean = ioc.getBean("person", Person.class);
//        System.out.println(bean);
//        Dog bean = ioc.getBean(Dog.class);
//        System.out.println(bean);
//        User bean = ioc.getBean(User.class);
//        Car bean = ioc.getBean(Car.class);
//        System.out.println(bean.getName());
    }

}
